#include "common/common.h"

struct UserInfo{
    char name[50];
    char phone[20];
};

int main(){
    char ip[20] = "123.57.102.65";
    int port = 8888;
    char name[50] = "林浩帆";
    char phone[20] = "18826075768";
    struct UserInfo info;
    strcpy(info.name, name);
    strcpy(info.phone, phone);
    
    int sockfd = connect_host(ip, port);

    if(sockfd == -1){
        perror("connect");
        exit(1);
    }

    int msg;
    while(1){
        recv(sockfd, &msg, sizeof(int), 0);
        if(msg == 1){
            send(sockfd, phone, strlen(phone), 0);
        }
        else if(msg == 2){
            send(sockfd, name, strlen(name), 0);
        }
        else if(msg == 3){
            send(sockfd, &info, sizeof(info), 0);
        }
        else{
            close(sockfd);
            return 0;
        }
    }
    return 0;
}